home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / profile.php < prev    next >
Encoding:
PHP Script  |  2005-03-14  |  11.0 KB  |  283 lines

  1. <?php 
  2. require_once('admin.php');
  3.  
  4. $title = 'Profile';
  5. $parent_file = 'profile.php';
  6.  
  7. $wpvarstoreset = array('action', 'profile', 'user');
  8. for ($i=0; $i<count($wpvarstoreset); $i += 1) {
  9.     $wpvar = $wpvarstoreset[$i];
  10.     if (!isset($$wpvar)) {
  11.         if (empty($_POST["$wpvar"])) {
  12.             if (empty($_GET["$wpvar"])) {
  13.                 $$wpvar = '';
  14.             } else {
  15.                 $$wpvar = $_GET["$wpvar"];
  16.             }
  17.         } else {
  18.             $$wpvar = $_POST["$wpvar"];
  19.         }
  20.     }
  21. }
  22.  
  23. require_once('../wp-config.php');
  24. auth_redirect();
  25. switch($action) {
  26.  
  27. case 'update':
  28.  
  29.     get_currentuserinfo();
  30.  
  31.     /* checking the nickname has been typed */
  32.     if (empty($_POST["newuser_nickname"])) {
  33.         die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
  34.         return false;
  35.     }
  36.  
  37.     /* if the ICQ UIN has been entered, check to see if it has only numbers */
  38.     if (!empty($_POST["newuser_icq"])) {
  39.         if ((ereg("^[0-9]+$",$_POST["newuser_icq"]))==false) {
  40.             die (__("<strong>ERROR</strong>: your ICQ UIN can only be a number, no letters allowed"));
  41.             return false;
  42.         }
  43.     }
  44.  
  45.     /* checking e-mail address */
  46.     if (empty($_POST["newuser_email"])) {
  47.         die (__("<strong>ERROR</strong>: please type your e-mail address"));
  48.         return false;
  49.     } else if (!is_email($_POST["newuser_email"])) {
  50.         die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
  51.         return false;
  52.     }
  53.  
  54.     $pass1 = $_POST["pass1"];
  55.     $pass2 = $_POST["pass2"];
  56.     do_action('check_passwords', array($user_login, &$pass1, &$pass2));
  57.  
  58.     if ( '' == $pass1 ) {
  59.         if ( '' != $pass2 )
  60.             die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
  61.         $updatepassword = "";
  62.     } else {
  63.         if ('' == $pass2)
  64.             die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
  65.         if ( $pass1 != $pass2 )
  66.             die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
  67.         $newuser_pass = $pass1;
  68.         $updatepassword = "user_pass=MD5('$newuser_pass'), ";
  69.         wp_clearcookie();
  70.         wp_setcookie($user_login, $newuser_pass);
  71.     }
  72.  
  73.     $newuser_firstname = wp_specialchars($_POST['newuser_firstname']);
  74.     $newuser_lastname = wp_specialchars($_POST['newuser_lastname']);
  75.     $newuser_nickname = $_POST['newuser_nickname'];
  76.     $newuser_nicename = sanitize_title($newuser_nickname);
  77.     $newuser_icq = wp_specialchars($_POST['newuser_icq']);
  78.     $newuser_aim = wp_specialchars($_POST['newuser_aim']);
  79.     $newuser_msn = wp_specialchars($_POST['newuser_msn']);
  80.     $newuser_yim = wp_specialchars($_POST['newuser_yim']);
  81.     $newuser_email = wp_specialchars($_POST['newuser_email']);
  82.     $newuser_url = wp_specialchars($_POST['newuser_url']);
  83.     $newuser_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $newuser_url) ? $newuser_url : 'http://' . $newuser_url; 
  84.     $newuser_idmode = wp_specialchars($_POST['newuser_idmode']);
  85.     $user_description = $_POST['user_description'];
  86.  
  87.     $result = $wpdb->query("UPDATE $wpdb->users SET user_firstname='$newuser_firstname', $updatepassword user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode', user_description = '$user_description', user_nicename = '$newuser_nicename' WHERE ID = $user_ID");
  88.  
  89.     wp_redirect('profile.php?updated=true');
  90. break;
  91.  
  92. case 'IErightclick':
  93.  
  94.     $bookmarklet_height= 550;
  95.  
  96.     ?>
  97.  
  98.     <div class="menutop"> IE one-click bookmarklet</div>
  99.  
  100.     <table width="100%" cellpadding="20">
  101.     <tr><td>
  102.  
  103.     <p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
  104.     <?php
  105.     $regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
  106.     ?>
  107.     <pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
  108.     <p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
  109.     window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
  110.     That's it, you can now right-click in an IE window and select <br />
  111.     'Post to WP' to make the bookmarklet appear. :)</p>
  112.  
  113.     <p align="center">
  114.       <form>
  115.         <input class="search" type="button" value="1" name="Close this window" />
  116.       </form>
  117.     </p>
  118.     </td></tr>
  119.     </table>
  120.     <?php
  121.  
  122. break;
  123.  
  124.  
  125. default:
  126.     $parent_file = 'profile.php';
  127.     include_once('admin-header.php');
  128.     $profiledata=get_userdata($user_ID);
  129.  
  130.     $bookmarklet_height= 440;
  131.  
  132. if (isset($updated)) { ?>
  133. <div class="updated">
  134. <p><strong><?php _e('Profile updated.') ?></strong></p>
  135. </div>
  136. <?php } ?>
  137. <div class="wrap">
  138. <h2><?php _e('Profile'); ?></h2>
  139. <form name="profile" id="profile" action="profile.php" method="post">
  140.     <p>
  141.     <input type="hidden" name="action" value="update" />
  142.     <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
  143.   </p>
  144.  
  145.   <table width="99%"  border="0" cellspacing="2" cellpadding="3" class="editform">
  146.     <tr>
  147.       <th width="33%" scope="row"><?php _e('Username:') ?></th>
  148.       <td width="67%"><?php echo $profiledata->user_login; ?></td>
  149.     </tr>
  150.     <tr>
  151.       <th scope="row"><?php _e('Level:') ?></th>
  152.       <td><?php echo $profiledata->user_level; ?></td>
  153.     </tr>
  154.     <tr>
  155.       <th scope="row"><?php _e('Posts:') ?></th>
  156.       <td>    <?php
  157.     $posts = get_usernumposts($user_ID);
  158.     echo $posts;
  159.     ?></td>
  160.     </tr>
  161.     <tr>
  162.       <th scope="row"><?php _e('First name:') ?></th>
  163.       <td><input type="text" name="newuser_firstname" id="newuser_firstname" value="<?php echo $profiledata->user_firstname ?>" /></td>
  164.     </tr>
  165.     <tr>
  166.       <th scope="row"><?php _e('Last name:') ?></th>
  167.       <td><input type="text" name="newuser_lastname" id="newuser_lastname2" value="<?php echo $profiledata->user_lastname ?>" /></td>
  168.     </tr>
  169.     <tr>
  170.       <th scope="row"><?php _e('Nickname:') ?></th>
  171.       <td><input type="text" name="newuser_nickname" id="newuser_nickname2" value="<?php echo $profiledata->user_nickname ?>" /></td>
  172.     </tr>
  173.     <tr>
  174.       <th scope="row"><?php _e('How to display name:') ?> </th>
  175.       <td><select name="newuser_idmode">
  176.         <option value="nickname"<?php
  177.     if ($profiledata->user_idmode == 'nickname')
  178.     echo ' selected="selected"'; ?>><?php echo $profiledata->user_nickname ?></option>
  179.         <option value="login"<?php
  180.     if ($profiledata->user_idmode=="login")
  181.     echo ' selected="selected"'; ?>><?php echo $profiledata->user_login ?></option>
  182.     <?php if ( !empty( $profiledata->user_firstname ) ) : ?>
  183.         <option value="firstname"<?php
  184.     if ($profiledata->user_idmode=="firstname")
  185.     echo ' selected="selected"'; ?>><?php echo $profiledata->user_firstname ?></option>
  186.     <?php endif; ?>
  187.     <?php if ( !empty( $profiledata->user_lastname ) ) : ?>
  188.         <option value="lastname"<?php
  189.     if ($profiledata->user_idmode=="lastname")
  190.     echo ' selected="selected"'; ?>><?php echo $profiledata->user_lastname ?></option>
  191.     <?php endif; ?>
  192.     <?php if ( !empty( $profiledata->user_firstname ) && !empty( $profiledata->user_lastname ) ) : ?>
  193.         <option value="namefl"<?php
  194.     if ($profiledata->user_idmode=="namefl")
  195.     echo ' selected="selected"'; ?>><?php echo $profiledata->user_firstname." ".$profiledata->user_lastname ?></option>
  196.     <?php endif; ?>
  197.     <?php if ( !empty( $profiledata->user_firstname ) && !empty( $profiledata->user_lastname ) ) : ?>
  198.         <option value="namelf"<?php
  199.     if ($profiledata->user_idmode=="namelf")
  200.     echo ' selected="selected"'; ?>><?php echo $profiledata->user_lastname." ".$profiledata->user_firstname ?></option>
  201.     <?php endif; ?>
  202.       </select>        </td>
  203.     </tr>
  204.     <tr>
  205.       <th scope="row"><?php _e('E-mail:') ?></th>
  206.       <td><input type="text" name="newuser_email" id="newuser_email2" value="<?php echo $profiledata->user_email ?>" /></td>
  207.     </tr>
  208.     <tr>
  209.       <th scope="row"><?php _e('Website:') ?></th>
  210.       <td><input type="text" name="newuser_url" id="newuser_url2" value="<?php echo $profiledata->user_url ?>" /></td>
  211.     </tr>
  212.     <tr>
  213.       <th scope="row"><?php _e('ICQ:') ?></th>
  214.       <td><input type="text" name="newuser_icq" id="newuser_icq2" value="<?php if ($profiledata->user_icq > 0) { echo $profiledata->user_icq; } ?>" /></td>
  215.     </tr>
  216.     <tr>
  217.       <th scope="row"><?php _e('AIM:') ?></th>
  218.       <td><input type="text" name="newuser_aim" id="newuser_aim2" value="<?php echo $profiledata->user_aim ?>" /></td>
  219.     </tr>
  220.     <tr>
  221.       <th scope="row"><?php _e('MSN IM:') ?> </th>
  222.       <td><input type="text" name="newuser_msn" id="newuser_msn2" value="<?php echo $profiledata->user_msn ?>" /></td>
  223.     </tr>
  224.     <tr>
  225.       <th scope="row"><?php _e('Yahoo IM:') ?> </th>
  226.       <td>        <input type="text" name="newuser_yim" id="newuser_yim2" value="<?php echo $profiledata->user_yim ?>" />      </td>
  227.     </tr>
  228.     <tr>
  229.       <th scope="row"><?php _e('Profile:') ?></th>
  230.       <td><textarea name="user_description" rows="5" id="textarea2" style="width: 99%; "><?php echo $profiledata->user_description ?></textarea></td>
  231.     </tr>
  232. <?php
  233. $show_password_fields = apply_filters('show_password_fields', true);
  234. if ( $show_password_fields ) :
  235. ?>
  236.     <tr>
  237.       <th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th>
  238.       <td><input type="password" name="pass1" size="16" value="" />
  239.           <br />
  240.         <input type="password" name="pass2" size="16" value="" /></td>
  241.     </tr>
  242. <?php endif; ?>
  243.   </table>
  244.   <p class="submit">
  245.     <input type="submit" value="<?php _e('Update Profile »') ?>" name="submit" />
  246.   </p>
  247. </form>
  248. </div>
  249.  
  250.  
  251. <?php if ($is_gecko && $profiledata->user_level != 0) { ?>
  252. <div class="wrap">
  253.     <script type="text/javascript">
  254. //<![CDATA[
  255. function addPanel()
  256.         {
  257.           if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
  258.             window.sidebar.addPanel("WordPress Post: <?php echo get_settings('blogname'); ?>","<?php echo get_settings('siteurl'); ?>/wp-admin/sidebar.php","");
  259.           else
  260.             alert(<?php __("'No Sidebar found!  You must use Mozilla 0.9.4 or later!'") ?>);
  261.         }
  262. //]]>
  263. </script>
  264.     <strong><?php _e('SideBar') ?></strong><br />
  265.     <?php _e('Add the <a href="#" onclick="addPanel()">WordPress Sidebar</a>!') ?> 
  266.     <?php } elseif (($is_winIE) || ($is_macIE)) { ?>
  267.     <strong><?php _e('SideBar') ?></strong><br />
  268.     <?php __('Add this link to your favorites:') ?><br />
  269. <a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;void(_search=open('<?php echo get_settings('siteurl');
  270.      ?>/wp-admin/sidebar.php?text='+escape(Q)+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title),'_search'))"><?php _e('WordPress Sidebar') ?></a>. 
  271.     
  272. </div>
  273. <?php } ?>
  274. </div>
  275.     <?php
  276.  
  277. break;
  278. }
  279.  
  280. /* </Profile | My Profile> */
  281. include('admin-footer.php');
  282.  ?>
  283.